﻿
Partial Class store_Manual
    Inherits CProductPage


#Region "Menu Locations"
    Protected Overrides ReadOnly Property TopPanel As System.Web.UI.WebControls.PlaceHolder
        Get
            Return plhTopLinks
        End Get
    End Property
    Protected Overrides ReadOnly Property SubPanel As System.Web.UI.WebControls.PlaceHolder
        Get
            Return plhSubLinks
        End Get
    End Property
    Protected Overrides ReadOnly Property SetPanel1 As System.Web.UI.Control
        Get
            Return plhSetMenu
        End Get
    End Property
    Protected Overrides ReadOnly Property SetPanel2 As System.Web.UI.Control
        Get
            Return plhSetMenu2
        End Get
    End Property
    Protected Overrides ReadOnly Property BottomLinks As System.Web.UI.HtmlControls.HtmlTableRow
        Get
            Return rowLinks
        End Get
    End Property
    Protected Overrides ReadOnly Property BottomRandom As System.Web.UI.HtmlControls.HtmlTableRow
        Get
            Return rowRandom
        End Get
    End Property
#End Region

#Region "Event Handlers - Page"
    Protected Overrides Sub PageInit()
        'deleted
        If IsNothing(Product) Then
            Response.RedirectPermanent(CSitemap.Manuals)
            Exit Sub
        End If

        'inactive
        If Not Product.ProductIsActive Then
            Response.Redirect(CSitemap.Manuals)
            Exit Sub
        End If

        'old url
        With Request.FilePath.ToLower
            If .Contains("training_manuals/") Then Response.RedirectPermanent(CSitemap.Decide(Product))
        End With

        'Name doesnt match
        If ProductName <> HttpUtility.UrlDecode(CConfig.SafeFriendlyName(Product.ProductName)) AndAlso Request.Url.Host <> "localhost" Then
            Response.RedirectPermanent(CSitemap.Decide(Product))
            Exit Sub
        End If

        lnkDonate.NavigateUrl = CSitemap.External_Donations
    End Sub
    Protected Overrides Sub PagePreRender()
        Dim mans As CProductList = CProduct.Cache.Active.Manuals
        NavLinks(lblNavManuals, mans, Product, CUtilities.NameAndCount("Manuals", mans), CSitemap.Manuals)

        With Product
            'Metadata
            Page.Title = .ProductName
            Page.MetaDescription = .ProductDescriptionOrParent
            Page.MetaKeywords = .ProductKeywordsOrParent

            'Set Image
            imgProduct.AlternateText = .ProductName
            imgProduct.ToolTip = .ProductName
            imgProduct.ImageUrl = CSitemap.ProductImage(Product)
            If Not IsNothing(Product.CSPaperback) Then
                imgProduct.ImageUrl = CSitemap.ProductImage(.CSPaperback) 'Paperback image is better
            End If
            imgFb.Attributes("href") = "http://mikeconnellministries.com" & imgProduct.ImageUrl.Substring(1)

            'Title/Desc
            litTitle.Text = HttpUtility.HtmlEncode(.ProductName)
            litDescription.Text = .Description_Br
            If .HasParent Then
                lnkParent.Text = String.Concat(.BelongsToName, " (", 1 + .BelongsTo.Children.IndexOf(Product), " of ", .BelongsTo.Children.Count, ")")
                lnkParent.NavigateUrl = CSitemap.Decide(.BelongsTo)
            End If

            'Keywords
            litKeywords.Text = .ProductKeywordsOrParent
            divKeywords.Visible = .ProductKeywordsOrParent.Trim.Length > 0

            'Iframe
            With .Files
                If .HasHtm Then
                    plhNotes.Visible = True
                    iframe.Visible = True
                    iframe.Attributes.Add("src", CConfig.DropboxUrl(.FirstHtm.FileName))
                    ctrlLinks.Display(Product)
                ElseIf .HasPdfOrWord Then
                    plhNotes.Visible = True
                    iframe.Visible = True
                    iframe.Attributes.Add("src", CConfig.DropboxUrl(.FirstPdfOrWord.FileName))
                End If
            End With



        End With
    End Sub
#End Region

#Region "Event Handlers - Form"
#End Region

#Region "User Controls"
#End Region

End Class

